<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>某个范围随机数，本次随机数和上次不重复</title>
    <style>
        body {
            height: 2000px;
        }

        .box {
            /* display: inline; */
            width: 100px;
            border-top: 50px solid red;
            border-right: 50px solid green;
            border-bottom: 50px solid blue;
            border-left: 50px solid pink;
        }

        .box2 {
            width: 100px;
            height: 100px;
            position: absolute;
            top: 200px;
            right: 20px;
            background-color: red;
        }
        .box6{
            width: 140px;
            height: 22px;
            line-height: 20px;
            overflow: hidden;
            /* border: 1px solid red; */
            font-size: 20px;
            background-image: linear-gradient(to right, #f1503b, #7e211a);
            -webkit-background-clip: text;
            background-clip: text;
            -webkit-text-fill-color: transparent;
            animation:  boxwidth 7s steps(17) infinite;

        }
        @keyframes boxwidth{
            0%{
                width: 20px;
                color: linear-gradient(0deg, #f1503b, #7e211a 50%);
            }
            100%{
                width: 360px;
            }
        }
    </style>
</head>

<body>

    <div class="box2">我是定位盒子</div>
    <div class="box3">
        <div class="inner1"></div>
        <div class="inner2"></div>
        <div class="inner3"></div>
        <div class="inner4"></div>
    </div>

    <ul class="box4">
        <li class="inner0"></li>
        <li class="inner1"></li>
        <li class="inner2"></li>
        <li class="inner3"></li>
        <li class="inner4"></li>
    </ul>
    <div class="box6">我是大魔王，我是张一鸣，我是中国人</div>
    <script src="./js/jquery-1.8.3.min.js"></script>
    <script>
        // 验证首尾有空格的字符串
        // var reg = /\d{4}[\-\s]?\d{4}[\-\s]?\d{2}/
        // var str11 = "2019-4567-08";
        // var str12 = "2019456708";
        // var str13 = "2019 4567 08";
        // console.log(reg.test(str11))
        // console.log(reg.test(str12))
        // console.log(reg.test(str13))

        // 验证手机号
        // var reg = /^[1][3578]{1}\d{9}$/
        // // var reg =/^[1[3578]{1}\d{9}$]/ 
        // // var reg =/^1[3578]\d{9}$/g
        // // var reg =/^1[3578]\d{9}/
        // var str11 = 18718137544;
        // var str12 = 19094856788;
        // var str13 = 13249773706;
        // var str14 = 23249773706;
        // console.log(reg.test(str11))  //true
        // console.log(reg.test(str12)) //false
        // console.log(reg.test(str13)) //true
        // console.log(reg.test(str14))   //false

        // 验证邮箱：
        var regphone = /^\w+[@]{1}[qqsina163]{1}[.com]{1}$/
        window.onload = function () {
            var ul = document.querySelector(".box4")

            window.addEventListener('scroll', function () {
                if (window.pageYOffset > 500) {
                    box2.style.position = 'fixed'
                }
                console.log('盒子position状态：' + box2.style.position)
            })

        }

        // 或者条件
        var reg = /^[\d][.com|.cn|.cm]$/
        var str11 = "290.com";
        var str13 = "qq.cm";
        var str12 = "qq.cn";
        // var str13 = "2019 4567 08";
        console.log(reg.test(str11))
        console.log(reg.test(str12))
        console.log(reg.test(str13))
        // 本次随机数和上次不重复
        var btn = document.querySelector(".btn")
        var box = document.querySelector(".box")
        var prenum = 0;
        // btn.onclick = function () {

        //     var current = Math.floor(Math.random() * 4)
        //     while (prenum == current) {
        //         current = Math.floor(Math.random() * 4)
        //     }
        //     prenum = current;
        //     console.log(prenum)
        // }

        // setInterval(() => {
        //     btn.onclick()
        // }, 500);


        // box.addEventListener('click', function () {
        //     this.style.width = '200px';
        //     this.style.transition = 'width 2s';
        // })

        // 封装一个节流函数
        function throttle(fn, delay) {
            let timer = null;
            return function (...args) {
                let context = this;
                if (!timer) {
                    fn.apply(context, args) //将函数放在这里，那么节流第一次就执行。之后每个一段时间生效一次
                    timer = setTimeout(() => {
                        // fn.apply(context, args)//将函数放在这里，那么第一次也是需要在某段时间后执行
                        timer = null
                    }, delay);
                }
            }
        }


        function test() {
            this.a = 1;
            this.c = function () {
                console.log(this.a)
            }

        }
        test.prototype = {
            b: function () {
                this.a = 2
                console.log(this.a)
            },
            c: function () {
                this.a = 3;
                console.log(this.a)
            }
        }
        var newtest = new test()
        newtest.b()
        newtest.c()


        let min = (numbers) => {
            if (numbers.length > 2) {
                return min(
                    [numbers[0], min(numbers.slice(1))]
                )
            } else {
                return Math.min.apply(null, numbers)
            }
        }
        var arr10 = [2, 3, 4, 53]
        console.log(min(arr10))
        min([2, [3, 4, 53]])
        min([2, [3, 4, 53]])

        // 日期的正则表达式以下格式都能匹配  /\d{4}[\-./\s]?\d{1,2}[\-./\s]?\d{1,2}/
        // 2021-07-28   
        // 2021-7-28 
        // 20210728  
        // 2021.07.28
        // 2021/07/28
        // var regdate = /\d{4}[\-./\s]?\d{1,2}[\-./\s]?\d{1,2}$/;
        // var str11 = "2021-07-28";
        // var str12 = "2021-7-28";
        // var str13 = "20210728";
        // var str14 = "2021.07.28";
        // var str15 = "2021/07/28";
        // // var str13 = "2019 4567 08";
        // console.log(regdate.test(str11))
        // console.log(regdate.test(str12))
        // console.log(regdate.test(str13))
        // console.log(regdate.test(str14))
        // console.log(regdate.test(str15))

        // 必须包含一个大写字母和小写字母还要数字，且长度不小于8
        var regdate = /(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9]).{8,}/
        var str11 = "akdAsd4"; //包含3种，但长度为7
        var str12 = "fdkjdf789"; //包含2种，长度可以
        var str13 = "fdkjdfD789";
        console.log(regdate.test(str11))
        console.log(regdate.test(str12))
        console.log(regdate.test(str13))

        var arr12 = [12, 2, 345, 6, 7]
        // arr12.every(e=>return e>7)
        var flag = arr12.every(function (item) {
            return item > 7
        })
        console.log(flag)

        function panduan(flagss) {
            if (flagss>0) {
                if (flagss> 2) {
                    console.log("里面")
                    return true;
                }
                console.log("外面")
            }
        }
        panduan(3)
    </script>
</body>

</html>